// Bachelor of Software Engineering 
// Media Design School 
// Auckland
// New Zealand
// 
// (c) 2005 - 2014 Media Design School 
// 
// File Name : Vector2.h
// Description : Vector2 header
// Author : Serge Radinovich
// Mail : srad015@hotmail.com

#pragma once
#include <math.h>
#include <iostream>


///////////////////////////////////////////////////////////////////////////////
// 2D vector
///////////////////////////////////////////////////////////////////////////////

struct Vector2
{
    int x;
    int y;

    // ctors
    Vector2() : x(0), y(0){};
    Vector2(int _iX, int _iY) : x(_iX), y(_iY) {};

	static int Distance(const Vector2& _lhs, const Vector2& _rhs);    


    // Utils functions
    void      Set(int _iX, int _iY);
    int       Magnitude() const;                         
    
    Vector2     Normalize();                            
    int       Dot(const Vector2& _kVec) const;          

    // Operators
	Vector2     operator-() const;                       
    Vector2     operator+(const Vector2& _kRHS) const;    
    Vector2     operator-(const Vector2& _kRHS) const;   
    Vector2&    operator+=(const Vector2& _kRHS);         
    Vector2&    operator-=(const Vector2& _kRHS);         
    Vector2     operator*(const int _kiScale) const;		
	friend Vector2 operator*(const int _kiScale, const Vector2& vec);
    Vector2     operator*(const Vector2& _kRHS) const;    
    Vector2&    operator*=(const int _kiScale);			
    Vector2&    operator*=(const Vector2& _kRHS);        
    Vector2     operator/(const int _kiScale) const;		
    Vector2&    operator/=(const int _kiScale);			
    bool        operator==(const Vector2& _kRHS) const;   
    bool        operator!=(const Vector2& _kRHS) const;   

    friend Vector2 operator*(const int _kiA, const Vector2 _kVec);
    friend std::ostream& operator<<(std::ostream& _rOS, const Vector2& _krVec);
};
